Skip to content

KeyError: 'piece_size' in fileNeed command in BigfilePlugin when try to download non-optional files with |all#2179

Merged
HelloZeroNet merged 1 commit intoHelloZeroNet:py3from
krzotr:patch-4
Aug 30, 2019
Merged

KeyError: 'piece_size' in fileNeed command in BigfilePlugin when try to download non-optional files with |all#2179
HelloZeroNet merged 1 commit intoHelloZeroNet:py3from
krzotr:patch-4

Conversation

@krzotr
Copy link
Copy Markdown
Contributor

@krzotr krzotr commented Aug 30, 2019

Step 1: Please describe your environment

  • ZeroNet version: 0.7.0 4197
  • Operating system: Fedora 30 x64
  • Web browser: Chromium 75.0.3770.100
  • Tor status: not available
  • Opened port: yes

Step 2: Describe the problem:

I try to use fileNeed command with |all to download data/mp4-redditgifs/9450.mp4 file from address1Gif7PqWTzVWDQ42Mo7np3zXmGAo3DXc7h. I received error {"error": "KeyError: piece_size"}

Steps to reproduce:

I used fileNeed to try download file, the most important thing is |all at the end.

{"cmd":"fileNeed","params":"data/mp4-redditgifs/9450.mp4|all","wrapper_nonce":"6a0201394d5a983802bed79f159fc037a8a6693603d09a6e227e65c64a170f8a","id":3}
{"cmd": "response", "to": 3, "result": {"error": "KeyError: piece_size"}, "id": 7}

Observed Results:

As you can see in response I got "error": "KeyError: piece_size". I enabled traceback:

Traceback (most recent call last):#### Expected Results:
  File "/home/ko/dev/zeronet/src/Ui/UiWebsocket.py", line 704, in actionFileNeed
    self.site.needFile(inner_path, priority=6)
  File "/home/ko/dev/zeronet/plugins/Bigfile/BigfilePlugin.py", line 757, in needFile
    piece_size = file_info["piece_size"]
KeyError: 'piece_size'

The problem is in BigfilePlugin.py in needFile function.

File data/mp4-redditgifs/9450.mp4 is not marked as optional file and piece_size does not exist in content.json file, check 1Gif7PqWTzVWDQ42Mo7np3zXmGAo3DXc7h/content.json:

  "data/mp4-redditgifs/9450.mp4": {
   "sha512": "36134aa4525d5985b1440d42e2b33580df56a179b4b0c71d0234947008a4fc12",
   "size": 1042259
  },

Expected Results:

If file is not marked as optional should be downloaded correcty with |all at the end.

I created patch which fixed this problem. If piece_size index does not exist in file_info - just use default needFile function from SitePlugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants